﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QQ
{
    class User
    {
         private static User user = null;
         private List<YongHu> list = new List<YongHu>();
         private List<Haoyou> hao = new List<Haoyou>();
        private User() { }
        public static User getUser() 
        {
            if (user == null)
            {
                user = new User();
            }
            return user;
        }
        public void AddUser(string userName,string pwd,string name) 
        {
            YongHu yong = new YongHu();
            yong.Pass = pwd;
            yong.yong = userName;
            yong.name = name;
            list.Add(yong);
        }
        public bool panDuan(string userName, string pwd) 
        {
            foreach (YongHu item in list)
            {
                if (item.yong.Equals(userName) && item.Pass.Equals(pwd) )
                {
                    return true;
                }
            }
            return false;
        }
        public List<YongHu> getYoghu()
        {
            return list;
        }
        public List<Haoyou> getList()
        {
            foreach (var item in list)
            {
                Haoyou yong = new Haoyou();
                yong.name = item.name;
                yong.yong = item.yong;
                hao.Add(yong);
            }
            return hao;
        }
    }
}
